package com.boomsecret.pattern.proxy;

import org.junit.Test;

/**
 * Created by wangjinliang on 2018/1/17.
 */
public class UserProxyTest {

    @Test
    public void testStaticProxy() {
        User user = new User();
        IUserDao userDao = new UserDaoImpl();
        IUserDao proxyUserDao = new UserStaticProxy(userDao);
        proxyUserDao.saveUser(user);
        proxyUserDao.updateUser(user);
    }

    @Test
    public void testDynamicsProxy() {
        User user = new User();
        IUserDao userDao = new UserDaoImpl();
        IUserDao proxyUserDao = new UserDynamicsProxy<IUserDao>().proxy(userDao);
        proxyUserDao.saveUser(user);
    }

    @Test
    public void testCglib() {
        User user = new User();
        UserDaoImpl userDao = new UserDaoImpl();
        UserDaoImpl userDaoProxy = new UserCglibProxy<UserDaoImpl>().proxy(userDao);
        userDaoProxy.saveUser(user);
    }
}
